package org.pictual.controller.mainPackage;

import java.io.BufferedReader;

public abstract class WikiDicTransParser extends MyParser {

    protected final static String pTag = "<p><a name=\"";

    abstract protected String WikiLang();
    abstract protected String TradToken();
    abstract protected boolean IsType(String type);

    public void Parse(BufferedReader input) {
        String rawLine = "";
        boolean insideLan = false;
        boolean insideTrad = false;
        try {
            while ((rawLine = input.readLine()) != null) {

                String line = rawLine.replaceAll("\t", "");
                if (line.startsWith(pTag)) {
                    //String nextLine = input.readLine();
                    String name = extractField(line, pTag.length());
                    if(!insideLan){
                        if(name.equals(WikiLang())){
                            insideLan = true;
                        }
                    } else if(!insideTrad){
                        if(name.equals(TradToken())){
                            insideLan = true;
                        }
                    } else if(IsType(name)){

                    }

                }
            }
        } catch (Exception e) {
        }
    }
}
